//
//  ViewController.m
//  WebView加载文件
//
//  Created by xiacl on 2018/9/5.
//  Copyright © 2018年 a2345. All rights reserved.
//

#import "ViewController.h"
#import "DocumentViewController.h"


@interface ViewController ()<UIDocumentInteractionControllerDelegate, QLPreviewControllerDataSource>
///**
// <#Description#>
// */
//@property (strong, nonatomic) UIDocumentInteractionController *documentController;
@end

@implementation ViewController
- (IBAction)other:(id)sender {
    
    /*
    NSString *str = [[NSBundle mainBundle] pathForResource:@"test.text" ofType:nil];
    NSCharacterSet *set = [NSCharacterSet URLQueryAllowedCharacterSet];
    NSString *encodedString = [str stringByAddingPercentEncodingWithAllowedCharacters:set];
//    NSURL *url = [NSURL URLWithString:encodedString];
    
    UIDocumentInteractionController *documentVC = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:encodedString]];
    
    documentVC.delegate = self;
    [documentVC presentOpenInMenuFromRect:CGRectMake(0, 0, self.view.bounds.size.width, 300) inView:self.view animated:YES];
    
    self.documentController = documentVC;
    
    */
    

    DocumentViewController *previewController = [[DocumentViewController alloc] init];
    //设置数据源
//    previewController.dataSource =self;
//    previewController.delegate = self;
//    previewController.hidesBottomBarWhenPushed = YES;
//    previewController.title = @"文件预览";
//    previewController.currentPreviewItemIndex = 0;
    
//    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"poto" ofType:@"png"]]
    
    NSArray *array = @[
//                      [NSURL fileURLWithPath: ],
//                       [[NSBundle mainBundle] pathForResource:@"guifan" ofType:@"docx"],
//                      [NSURL fileURLWithPath:  [[NSBundle mainBundle] pathForResource:@"test" ofType:@"text"]],
//                      [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"方法论" ofType:@"pptx"]],
//                       [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Fiddler-给手机设置代理" ofType:@"pdf"]],
//                       [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"章鱼星球APP-V2.0测试用例(1)" ofType:@"xlsx"]],
//                       [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"NAS" ofType:@"zip"]],
//                       [[NSBundle mainBundle] pathForResource:@"NAS" ofType:@"zip"],
//                       [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"poto" ofType:@"png"]],
//                       [[NSBundle mainBundle] pathForResource:@"bbbbbb" ofType:@"pxcp"]
//                        [NSURL fileURLWithPath:],
//                       @"https://www.baidu.com",
                       [[NSBundle mainBundle] pathForResource:@"Fiddler-给手机设置代理" ofType:@"pdf"],
//                        @"https://www.baidu.com",
//
//                       [[NSBundle mainBundle] pathForResource:@"SecureCRT" ofType:@"zip"],
                      
//                      [NSURL URLWithString:@"https://www.baidu.com"]
                       ];
    previewController.pathURL = array;
    [self.navigationController pushViewController:previewController animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

//- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application{
//    NSLog(@"%s", __func__);
//}
//
//- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application{
//    NSLog(@"%s", __func__);
//}
//
//- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller{
//    NSLog(@"%s", __func__);
//}
//
//
//- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
//    return 8;
//
//}
//
//- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
//    NSString *path = nil;
//    if (index == 0) {
//        path = [[NSBundle mainBundle] pathForResource:@"abc" ofType:@"docx"];
//    } else if (index == 1){
//       path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"text"];
//    } else if (index == 2) {
//         path = [[NSBundle mainBundle] pathForResource:@"方法论" ofType:@"pptx"];
//    } else if (index == 3) {
//        path = [[NSBundle mainBundle] pathForResource:@"Fiddler-给手机设置代理" ofType:@"pdf"];
//    } else if (index == 4) {
//        path = [[NSBundle mainBundle] pathForResource:@"章鱼星球APP-V2.0测试用例(1)" ofType:@"xlsx"];
//    } else if (index == 5) {
//        path = [[NSBundle mainBundle] pathForResource:@"NAS" ofType:@"zip"];
//    } else if (index == 6) {
//        path = [[NSBundle mainBundle] pathForResource:@"bbbbbb" ofType:@"pxcp"];
//    } else if (index == 7) {
//         path = [[NSBundle mainBundle] pathForResource:@"poto" ofType:@"png"];
//    }
//
//     NSURL *url = [NSURL fileURLWithPath:path];
//
//    if ([QLPreviewController canPreviewItem:url]) {
//        return url;
//    }
//    return nil;
//
//}

    
    
   

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
